<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/22
 * Time: 23:33
 */

namespace zch\firstLaravel\application;

use zch\firstLaravel\container\Container;
use zch\firstLaravel\database\MySQL;

class Application extends Container
{
    public function __construct()
    {
        $this->registerBaseBindings();
        $this->registerBaseService();
    }

    //定义系统服务注册
    public function registerBaseBindings()
    {
        $bind = [
           'mysql' => MySQL::class
        ];
        foreach ($bind as $key => $val){
            $this->bind($key, $val);
        }
    }

    //事先绑定这个 程序需要的共享实例
    public function registerBaseService()
    {
        $this->instance('app', $this);
        $this->instance(Container::class, $this);
    }

    public function make($abstract, $parameters = [])
    {
        if(!$this->has($abstract)){
            return $abstract;
        }
        return parent::make($abstract, $parameters);
    }
    
}